package com.lovo.atm;

/**
 * 用户类
 */
public class User {
    /**
     * 账号
     */
    private String account;
    /**
     * 密码
     */
    private String pwd;
    /**
     * 余额
     */
    private double blance;
    public User(){}
    public User(String account,String pwd,double blance){
        this.account = account;
        this.pwd = pwd;
        this.blance = blance;
    }

    /**
     * 校验当前账户的账号和密码是否与传进来的账号和密码一致
     * @param account
     * @param pwd
     * @return true:验证成功；false：验证失败
     */
    public boolean validate(String account,String pwd){
//        if(this.account.equals(account) && this.pwd.equals(pwd)){
//            return true;
//        }
//        return false;
        return this.account.equals(account) && this.pwd.equals(pwd);
    }
    /**
     * 将钱加到当前对象的余额上
     * @param blance 需要增加的金额
     */
    public void add(double blance){
        this.blance += blance;
    }

    /**
     * 将钱从当前余额上扣去
     * @param blance 扣去的金额
     * @return true：扣去成功；false：余额不足
     */
    public boolean minus(double blance){
        if(this.blance < blance){
            return false;
        }
        this.blance -= blance;
        return true;
    }

    /**
     * 获取当前账户的余额
     * @return 当前账户的余额
     */
    public double getBlance(){
        return this.blance;
    }


    /**
     * 密码的更新
     * @param pwd
     */
    public void setPwd(String pwd){
        this.pwd = pwd;
    }

    /**
     * 获取当前账户的密码
     * @return
     */
    public String getPwd(){
        return this.pwd;
    }
    public String getAccount(){
        return account;
    }

}
